<?php
if($this->styleForm === NULL)
	include BXD_INCLUDEPATH . 'components/tools/form/style/default.php';

if($this->showError && !$this->showCustomError)
	echo '<div id="errorForm' . ucfirst($param['NAME']) . '" class="listErrorForm"></div>';
?>

<script type="text/javascript">
	function submitForm<?= ucfirst($param['NAME']); ?>(){
		$.ajax({
			type: "<?= ($param['METHOD'] == 'post') ? 'POST' : 'GET' ?>",
			url: "<?= $param['ACTION'] ?>",
			data: $("form[name=<?= $param['NAME'] ?>]").serialize(),
			dataType: "json",
			success: function(data){
				if(data.result == "OK"){
					<?php
					if($this->showError)
						echo '$("#errorForm' . ucfirst($param['NAME']) . '").html("");';

					if(is_string($param['DIALOG_BOX']))
						echo '$("#' . $param['DIALOG_BOX'] . '").dialog("close").html("");';

					if(is_string($param['CALLBACK_FUNCTION']))
						echo $param['CALLBACK_FUNCTION'] . "();";
					?>
				}else{
					printErrorList(data.errorList, 'errorForm<?= ucfirst($param['NAME']); ?>');
				}
			},
			beforeSend: function(){
				$('#errorForm<?= ucfirst($param['NAME']); ?>').html("<div class='loading'>Attendere prego...</div>");
			}
		});
	}

	function resetForm<?= ucfirst($param['NAME']); ?>(){
		$("form[name=<?= $param['NAME'] ?>]")[0].reset();
	}
</script>

<form class="<?= $this->styleForm !== NULL ? $this->styleForm : '' ?>" name="<?= $param['NAME'] ?>" action="javascript:submitForm<?= ucfirst($param['NAME']); ?>()">